package thread;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author zhangxin
 * @date 2020/9/28
 */
public class DaemonThread {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            try {
                FileOutputStream fileOutputStream = new FileOutputStream("C:\\Users\\zhangxin\\Desktop\\daemeon.txt");
                fileOutputStream.write("Java".getBytes());

                fileOutputStream.flush();
                fileOutputStream.close();
                Thread.sleep(3000);

            } catch (FileNotFoundException e) {
                e.printStackTrace();
            } catch (IOException e) {


            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });

        thread.setDaemon(true);
        thread.start();

        Thread.sleep(5000L);
    }
}

